// ignore_for_file: unused_import, unnecessary_import

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:ts_app_dart/langs/index.dart';
import 'package:ts_app_dart/navigators/entrance_bottom_bar.dart';
import 'package:ts_app_dart/routers/index.dart';
import 'package:flutter/rendering.dart';
import 'package:ts_app_dart/navigators/bottom_navigattion.dart';
import 'package:ts_app_dart/utils/index.dart';

void main() {
  // debugDumpRenderTree();
  // debugPaintSizeEnabled = true;

  CommonUtils.initCoreInts();

  runApp(MyApp());

  if (Platform.isAndroid) {
    //设置Android头部的导航栏透明
    SystemUiOverlayStyle systemUiOverlayStyle =
        SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }
}

class MyApp extends StatelessWidget {
  final int count = 1;
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    // return MaterialApp(
    //   debugShowMaterialGrid: false,
    //   title: 'Flutter Dart',
    //   theme: ThemeData(
    //     primarySwatch: Colors.blue,
    //   ),
    //   home: EntranceBottomBar(),
    // );

    return GetMaterialApp(
      title: 'Flutter Dart',
      // home: EntranceBottomBar(),
      translations: AppTranslations(),
      locale: Locale('zh', 'CN'),
      // 添加一个回调语言选项，以备上面指定的语言翻译不存在
      fallbackLocale: Locale('en', 'US'),
      routes: Routes.routes,
      initialRoute: count > 5 ? Routes.initial : '/splash',
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
  }

  @override
  Widget build(BuildContext context) {
    return BootomNavigation();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    super.didChangeAppLifecycleState(state);
    switch (state) {
      case AppLifecycleState.paused:
        // FlutterAppBadger.updateBadgeCount(8);
        break;
      case AppLifecycleState.resumed:
        print('-------------------> $state');
        break;
      default:
      // print('-------------------> $state');
    }
  }
}
